/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EditData.java
 *
 * Created on Sep 23, 2010, 11:12:39 PM
 */

package cat200project;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
 *
 * @author Akmal
 */
public class CUS_RESERVATION_EDIT extends javax.swing.JFrame {

    Statement stat;
    Connection con;
    ResultSet rset;
    private String url = "jdbc:oracle:thin:@localhost:1521:XE";
    private String pass_id = "restaurant";
    private String pass_pw = "restaurant";
    String tableNum = "1";

    /** Creates new form EditData */
    public CUS_RESERVATION_EDIT() throws SQLException {
        super("RESERVATION");
        initComponents();
        this.setLocationRelativeTo(null);
        connect();
        start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        Cancel = new javax.swing.JButton();
        Done = new javax.swing.JButton();
        InfoPane = new javax.swing.JPanel();
        jLayeredPane2 = new javax.swing.JLayeredPane();
        YearReserve = new javax.swing.JComboBox();
        MonthReserve = new javax.swing.JComboBox();
        DayReserve = new javax.swing.JComboBox();
        PersonNum = new javax.swing.JComboBox();
        PaymentType = new javax.swing.JComboBox();
        PhoneNum = new javax.swing.JTextField();
        LastName = new javax.swing.JTextField();
        FirstName = new javax.swing.JTextField();
        PersonNumField = new javax.swing.JTextField();
        DateReserve = new javax.swing.JTextField();
        PaymentTypeField = new javax.swing.JTextField();
        edit = new javax.swing.JButton();
        delete = new javax.swing.JButton();
        save = new javax.swing.JButton();
        SearchBy = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18));
        jLabel1.setText("EDIT RESERVATION");
        jLabel1.setBounds(60, 0, 250, 50);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jSeparator1.setBounds(0, 50, 700, 10);
        jLayeredPane1.add(jSeparator1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jSeparator2.setBounds(0, 440, 700, 10);
        jLayeredPane1.add(jSeparator2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Cancel.setFont(new java.awt.Font("Times New Roman", 1, 12));
        Cancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Cancel.setText("CANCEL");
        Cancel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelActionPerformed(evt);
            }
        });
        Cancel.setBounds(480, 450, 90, 40);
        jLayeredPane1.add(Cancel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Done.setFont(new java.awt.Font("Times New Roman", 1, 12));
        Done.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        Done.setText("DONE");
        Done.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Done.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DoneActionPerformed(evt);
            }
        });
        Done.setBounds(580, 450, 90, 40);
        jLayeredPane1.add(Done, javax.swing.JLayeredPane.DEFAULT_LAYER);

        InfoPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        YearReserve.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Year", "2010", "2011" }));
        YearReserve.setEnabled(false);
        YearReserve.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                YearReserveActionPerformed(evt);
            }
        });
        YearReserve.setBounds(530, 150, 70, 20);
        jLayeredPane2.add(YearReserve, javax.swing.JLayeredPane.DEFAULT_LAYER);

        MonthReserve.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }));
        MonthReserve.setEnabled(false);
        MonthReserve.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MonthReserveActionPerformed(evt);
            }
        });
        MonthReserve.setBounds(430, 150, 90, 20);
        jLayeredPane2.add(MonthReserve, javax.swing.JLayeredPane.DEFAULT_LAYER);

        DayReserve.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Day", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        DayReserve.setEnabled(false);
        DayReserve.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DayReserveActionPerformed(evt);
            }
        });
        DayReserve.setBounds(360, 150, 60, 20);
        jLayeredPane2.add(DayReserve, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PersonNum.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select...", "1", "2", "3", "4", "5", "6" }));
        PersonNum.setEnabled(false);
        PersonNum.setBounds(360, 180, 70, 20);
        jLayeredPane2.add(PersonNum, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PaymentType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select..", "Cash", "Credit Card" }));
        PaymentType.setEnabled(false);
        PaymentType.setBounds(360, 210, 130, 20);
        jLayeredPane2.add(PaymentType, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PhoneNum.setFocusable(false);
        PhoneNum.setBounds(220, 240, 170, 20);
        jLayeredPane2.add(PhoneNum, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LastName.setFocusable(false);
        LastName.setBounds(220, 120, 170, 20);
        jLayeredPane2.add(LastName, javax.swing.JLayeredPane.DEFAULT_LAYER);

        FirstName.setFocusable(false);
        FirstName.setBounds(220, 90, 170, 20);
        jLayeredPane2.add(FirstName, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PersonNumField.setFocusable(false);
        PersonNumField.setBounds(220, 180, 130, 20);
        jLayeredPane2.add(PersonNumField, javax.swing.JLayeredPane.DEFAULT_LAYER);

        DateReserve.setFocusable(false);
        DateReserve.setBounds(220, 150, 130, 20);
        jLayeredPane2.add(DateReserve, javax.swing.JLayeredPane.DEFAULT_LAYER);

        PaymentTypeField.setFocusable(false);
        PaymentTypeField.setBounds(220, 210, 130, 20);
        jLayeredPane2.add(PaymentTypeField, javax.swing.JLayeredPane.DEFAULT_LAYER);

        edit.setFont(new java.awt.Font("Times New Roman", 1, 12));
        edit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        edit.setText("EDIT");
        edit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        edit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editActionPerformed(evt);
            }
        });
        edit.setBounds(290, 310, 90, 30);
        jLayeredPane2.add(edit, javax.swing.JLayeredPane.DEFAULT_LAYER);

        delete.setFont(new java.awt.Font("Times New Roman", 1, 12));
        delete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        delete.setText("DELETE");
        delete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        delete.setBounds(500, 310, 90, 30);
        jLayeredPane2.add(delete, javax.swing.JLayeredPane.DEFAULT_LAYER);

        save.setFont(new java.awt.Font("Times New Roman", 1, 12));
        save.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        save.setText("SAVE");
        save.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveActionPerformed(evt);
            }
        });
        save.setBounds(390, 310, 100, 30);
        jLayeredPane2.add(save, javax.swing.JLayeredPane.DEFAULT_LAYER);

        SearchBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select...", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        SearchBy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchByActionPerformed(evt);
            }
        });
        SearchBy.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                SearchByPropertyChange(evt);
            }
        });
        SearchBy.setBounds(310, 10, 80, 30);
        jLayeredPane2.add(SearchBy, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel11.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel11.setText("Search Table Number :");
        jLabel11.setBounds(170, 10, 130, 30);
        jLayeredPane2.add(jLabel11, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel2.setText("Last Name :");
        jLabel2.setBounds(30, 120, 110, 20);
        jLayeredPane2.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel4.setText("Amount Of Person:");
        jLabel4.setBounds(30, 180, 130, 20);
        jLayeredPane2.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel3.setText("Date For Reservation:");
        jLabel3.setBounds(30, 150, 140, 20);
        jLayeredPane2.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel6.setText("Payment Type:");
        jLabel6.setBounds(30, 210, 120, 20);
        jLayeredPane2.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel9.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel9.setText("Phone Number:");
        jLabel9.setBounds(30, 240, 130, 20);
        jLayeredPane2.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel7.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jLabel7.setText("First Name :");
        jLabel7.setBounds(30, 90, 100, 20);
        jLayeredPane2.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract_0072.jpg"))); // NOI18N
        jLabel8.setText("jLabel8");
        jLabel8.setBounds(0, -10, 640, 370);
        jLayeredPane2.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout InfoPaneLayout = new javax.swing.GroupLayout(InfoPane);
        InfoPane.setLayout(InfoPaneLayout);
        InfoPaneLayout.setHorizontalGroup(
            InfoPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
        );
        InfoPaneLayout.setVerticalGroup(
            InfoPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
        );

        InfoPane.setBounds(40, 60, 630, 360);
        jLayeredPane1.add(InfoPane, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/abstract2.jpg"))); // NOI18N
        jLabel10.setText("jLabel10");
        jLabel10.setBounds(0, 0, 700, 500);
        jLayeredPane1.add(jLabel10, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void MonthReserveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MonthReserveActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_MonthReserveActionPerformed

    private void DayReserveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DayReserveActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_DayReserveActionPerformed

    private void YearReserveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_YearReserveActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_YearReserveActionPerformed

    private void CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelActionPerformed
        new EMPLOYEE_MENU().setVisible(true);
        this.dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_CancelActionPerformed

    private void DoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DoneActionPerformed
        new EMPLOYEE_MENU().setVisible(true);
        this.setVisible(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_DoneActionPerformed

    private void SearchByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchByActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_SearchByActionPerformed

    private void SearchByPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_SearchByPropertyChange

        SearchBy.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (SearchBy.getSelectedIndex() == 1)
        {
            tableNum = "1";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        
                    }
        }
        else if ( SearchBy.getSelectedIndex()== 2){
            tableNum = "2";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        
                    }
        }
        else if ( SearchBy.getSelectedIndex()== 3){
            tableNum = "3";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        
                    }
        }
       else if ( SearchBy.getSelectedIndex()== 4){
            tableNum = "4";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        
                    }
        }
        else if ( SearchBy.getSelectedIndex()== 5){
            tableNum = "5";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                       
                    }
        }
        else if ( SearchBy.getSelectedIndex()== 6){
            tableNum = "6";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        
                    }
        }
        else if ( SearchBy.getSelectedIndex()== 7){
            tableNum = "7";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                       
                    }
        }
        else if ( SearchBy.getSelectedIndex()== 8){
            tableNum = "8";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        
                    }
        }
        else if ( SearchBy.getSelectedIndex()== 9){
            tableNum = "9";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        
                    }
        }
        else if ( SearchBy.getSelectedIndex()== 10){
            tableNum = "10";
            clearall();
                    try {
                        
                        start();
                    } catch (SQLException ex) {
                        Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                        
                    }
        }
            }
        });
        // TODO add your handling code here:
    }//GEN-LAST:event_SearchByPropertyChange

    private void editActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editActionPerformed

        delete.setEnabled(false);
        SearchBy.setEnabled(false);
        PersonNumField.setText("");
        PaymentTypeField.setText("");
        DateReserve.setText("");

        DateReserve.setEnabled(false);
        PersonNumField.setEnabled(false);
        PaymentTypeField.setEnabled(false);
        DayReserve.setEnabled(true);
        MonthReserve.setEnabled(true);
        YearReserve.setEnabled(true);
        PersonNum.setEnabled(true);
        PaymentType.setEnabled(true);
        FirstName.setFocusable(true);
        LastName.setFocusable(true);
        PhoneNum.setFocusable(true);

        // TODO add your handling code here:
    }//GEN-LAST:event_editActionPerformed

    private void saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveActionPerformed

        String a = FirstName.getText();
        String b = LastName.getText();
        String dd = (String) DayReserve.getSelectedItem();
        String mm = (String) MonthReserve.getSelectedItem();
        String yy = (String) YearReserve.getSelectedItem();
        String c = dd+" "+mm+" "+yy;
        String table = (String) SearchBy.getSelectedItem();
        String e = (String) PersonNum.getSelectedItem();
        String f = (String) PaymentType.getSelectedItem();
        String g = PhoneNum.getText();

        String query = "UPDATE RESERVATION SET CUS_FNAME = '"+ a +"',CUS_LNAME = '"+ b +"',"+
                        "CUS_PERSON_NO = '"+ e +"',CUS_PAYTYPE = '"+ f +"',CUS_PHONENUM = '"+ g +"'"+
                        ",CUS_DATE_RESERVE = '"+ c +"' WHERE CUS_TABLENO = '"+ table +"'";
        String message = "Are you sure you want to update?";
        String title = "Confirmation";
        
        if(dd.equals("Day") || mm.equals("Month") || yy.equals("Year"))
        {
            JOptionPane.showMessageDialog(null, "Input/Select properly!");
        }
        else
        {
            int reply = JOptionPane.showConfirmDialog(null,message,title,JOptionPane.YES_NO_OPTION);
            if(reply == JOptionPane.YES_OPTION)
            {
                try {
                    stat = con.createStatement();
                    stat.executeUpdate(query);

                    JOptionPane.showMessageDialog(null, "Update successful");

                    DateReserve.setEnabled(true);
                    PersonNumField.setEnabled(true);
                    PaymentTypeField.setEnabled(true);
                    DayReserve.setEnabled(false);
                    MonthReserve.setEnabled(false);
                    YearReserve.setEnabled(false);
                    PersonNum.setEnabled(false);
                    PaymentType.setEnabled(false);
                    FirstName.setFocusable(false);
                    LastName.setFocusable(false);
                    PhoneNum.setFocusable(false);
                    SearchBy.setSelectedIndex(0);

                    clearall();
                    SearchBy.setEnabled(true);
                    delete.setEnabled(true);
                }
                catch (SQLException ex)
                {
                    Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                    JOptionPane.showMessageDialog(null, "Update failed!");
                }

            }
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_saveActionPerformed

    private void Display() throws SQLException
    {
        FirstName.setText(rset.getString("CUS_FNAME"));
        LastName.setText(rset.getString("CUS_LNAME"));
        PhoneNum.setText(rset.getString("CUS_PHONENUM"));
        PersonNumField.setText(rset.getString("CUS_PERSON_NO"));
        PaymentTypeField.setText(rset.getString("CUS_PAYTYPE"));
        DateReserve.setText(rset.getString("CUS_DATE_RESERVE"));
    }

    private void start() throws SQLException
    {
        String query = "SELECT * FROM RESERVATION WHERE CUS_TABLENO ='"+ tableNum +"'";
        rset = getResultSet(query);
        if(rset.next())
        {
            Display();
        }
    }

    private ResultSet getResultSet(String s) throws SQLException {
        connect();
        ResultSet rs = null;
        try {
            stat = con.createStatement();
            rs = stat.executeQuery(s);
        } catch (SQLException ex) {
            Logger.getLogger(MENU_SELECTION_APP.class.getName()).log(Level.SEVERE, null, ex);
        }

        return rs;
    }

    private void clearall()
    {
        FirstName.setText("");
        LastName.setText("");
        DayReserve.setSelectedIndex(0);
        MonthReserve.setSelectedIndex(0);
        YearReserve.setSelectedIndex(0);
        PhoneNum.setText("");
        PersonNum.setSelectedIndex(0);
        PaymentType.setSelectedIndex(0);
        PersonNumField.setText("");
        PaymentTypeField.setText("");
        DateReserve.setText("");
    }

    private void connect() throws SQLException
    {
         try {
            //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
            System.out.println("Driver Loaded");
            con = DriverManager.getConnection(url,pass_id,pass_pw);
            System.out.println("Database Connected");

         }
         catch (Exception ex)
         {
            Logger.getLogger(MENU_SELECTION_MAIN.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new CUS_RESERVATION_EDIT().setVisible(true);
                } catch (SQLException ex) {
                    Logger.getLogger(CUS_RESERVATION_EDIT.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Cancel;
    private javax.swing.JTextField DateReserve;
    private javax.swing.JComboBox DayReserve;
    private javax.swing.JButton Done;
    private javax.swing.JTextField FirstName;
    private javax.swing.JPanel InfoPane;
    private javax.swing.JTextField LastName;
    private javax.swing.JComboBox MonthReserve;
    private javax.swing.JComboBox PaymentType;
    private javax.swing.JTextField PaymentTypeField;
    private javax.swing.JComboBox PersonNum;
    private javax.swing.JTextField PersonNumField;
    private javax.swing.JTextField PhoneNum;
    private javax.swing.JComboBox SearchBy;
    private javax.swing.JComboBox YearReserve;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton delete;
    private javax.swing.JButton edit;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLayeredPane jLayeredPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton save;
    // End of variables declaration//GEN-END:variables

}
